<template>
   <div>
      <!-- 文本自动获取焦点 -->
      <input  type="text" />
      <br/>
      <input  type="text" ref="demo" />

   </div>
</template>
<script lang = "ts">
import { defineComponent, ref, onMounted , } from 'vue'
export default defineComponent({
  name: 'life',
  setup(){
     const  demo = ref<HTMLElement |null>(null)
     onMounted(()=>{
        demo.value  && demo.value.focus()
     })

     return {
        demo
     }
  }
})
</script>

